<?php

namespace app\admin\controller;

use app\model\User as UserModel;
use think\Db;
class User extends Common
{
    public function Listcy()
    {
        return $this->fetch();
    }

    /**作者：lyx
     * 返回前端接口
     * 
     */

    public function getUserData()
    {

        $page = request()->param('page');
        $limit = request()->param('limit');
        $id=request()->param('id');
         $start=($page-1)*$limit;
        if($id==''){
        $userinfo=UserModel::where('role',0)->limit($start,$limit)->select();
        $count=count(UserModel::where('role',0)->select());
        }else{
            $userinfo=UserModel::where('role',0)->where('id',$id)->limit($start,$limit)->select();
            $count=count(UserModel::where('role',0)->where('id',$id)->select());
        }
        $msg=[
            'code'=>0,
            'msg'=>'查询成功',
            'data'=>$userinfo,
            'count'=>$count,
        ];
        echo json_encode($msg); 
        die;
    }

    public function edit()      
    {
        $data=request()->only(['role','id','status']);

        return (new UserModel())->edit($data);

    }
}
